using System;
using L=Science.Physics.GeneralPhysics;

namespace Serway.Chapter03
{
	/// <summary>
	/// Example04: The Resultant Displacement
	/// A particle undergoes three consecutive displacements:
	/// d_1 = (15i + 30j + 12k) cm, d_2 =(23i - 14j - 5k) cm 
	/// and d_3 = (-13i + 15j) cm. Find the components of the 
	/// resultant and its magnitude.
	/// </summary>
	public class Example04
	{
		public Example04()
		{
		}
		private string result;
		public string Result
		{
			get{return result;}
		}
		public void Compute()
		{
			L.Displacement d1 = new L.Displacement();
			d1.X = 15.0;
			d1.Y = 30.0;
			d1.Z = 12.0;
			L.Displacement d2 = new L.Displacement();
			d2.X = 23.0;
			d2.Y = -14.0;
			d2.Z = -5.0;
			L.Displacement d3 = new L.Displacement();
			d3.X = -13.0;
			d3.Y = 15.0;
			d3.Z = 0.0;
			L.Vector res = (d1+(d2+d3));
			result += Convert.ToString(res.X)+" ";
			result += Convert.ToString(res.Y)+" ";
			result += Convert.ToString(res.Z)+" ";
			result += Convert.ToString(res.Norm)+" ";
			result += Convert.ToString(Math.Sqrt(25*25+31*31+7*7));
		}
	}
}
